<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>05-v-on的使用</title>
</head>

<body>
  <div id="app">
    <!-- 不带参数的按钮事件监听 -->
    <button @click="buttonClick">按钮1</button>
    <!-- 不带参数的按钮事件监听 -->
    <button @click="buttonClick2(fullName)">按钮2</button>

    <!-- v-on 修饰符 stop -->
    <div @click="divClick">div
      <button @click.stop="buttonClick3">按钮3</button>
    </div>

    <!-- v-on 修饰符 prevent -->
    <form action="baidu">
      <input type="submit" value="提交" @click.prevent="submitClick">
    </form>
    <input type="text" name="txt" value="hello world" @change="changeAction">
    <input type="text" name="pwd" value=">>>" @focus="focusAction" @blur="blurAction">
  </div>

  <script src="./js/vue.js"></script>
  <script>
    const app = new Vue({
      el: '#app',
      methods: {
        buttonClick() {
          console.log(event);
        },

        buttonClick2(fullName) {
          console.log(fullName);
        },

        buttonClick3() {
          console.log("buttonClick3");
        },
        divClick() {
          console.log("divClick");
        },

        submitClick() {
          console.log("submitClick");
        },
        changeAction() {
          console.log("changeAction");
        },
        blurAction() {
          console.log(event.target.value);
        },
        focusAction() {
          console.log(event.target.value);
        }
      },
      computed: {
        fullName: function () {
          return this.firstName + ' ' + this.lastName
        }
      },
      data: {
        firstName: "Jone",
        lastName: "Brown"
      }
    })
  </script 
</body>
</html>